package micotime.com.amap_plugin.map.channel;

import android.content.Context;

import com.amap.api.location.AMapLocationClient;
import com.amap.api.maps.TextureMapView;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;

/**
 * 地图相关方法调用
 */
public class AMapViewMethodChannel extends AbstractMethodChannel {

    /**
     * 设置最大缩放级别
     */
    private final static String METHOD_CHANNEL_SET_MAX_ZOOM_LEVEL = "setMaxZoomLevel";

    /**
     * 设置最小放大级别
     */
    private final static String METHOD_CHANNEL_SET_MIN_ZOOM_LEVEL = "setMinZoomLevel";

    /**
     *获取比例尺数据。当前缩放级别下，地图上1像素点对应的长度，单位米。
     */
    private final static String METHOD_CHANNEL_GET_SCALE_PER_PIXEL="getScalePerPixel";

    /**
     * 根据转入的屏幕位置返回一个地图位置（经纬度）。
     */
    private final static String METHOD_CHANNEL_FROM_SCREEN_LOCATION = "fromScreenLocation";

    public AMapViewMethodChannel(Context context, TextureMapView mapView) {
        super(context,mapView);
    }

    @Override
    public void process(MethodCall methodCall, MethodChannel.Result result) {
        switch (methodCall.method){
            case METHOD_CHANNEL_SET_MAX_ZOOM_LEVEL:
                setMaxZoomLevel((float) methodCall.arguments);
                break;
            case METHOD_CHANNEL_SET_MIN_ZOOM_LEVEL:
                setMinZoomLevel((float) methodCall.arguments);
                break;
            case METHOD_CHANNEL_GET_SCALE_PER_PIXEL:
                result.success(this.aMap.getScalePerPixel());
                break;
            case METHOD_CHANNEL_FROM_SCREEN_LOCATION:
               // result.success(this.mapView.getMap().tos);

        }
    }

    private void setMaxZoomLevel(float zoomLevel) {
        this.aMap.setMaxZoomLevel(zoomLevel);
    }

    private void setMinZoomLevel(float zoomLevel) {
        this.aMap.setMinZoomLevel(zoomLevel);
    }


}
